<template>
	<view class='page_cont'>
		<view class='box'>
			<view class='text_wrap' @click='chage_focus()' v-if="!text&&!focus">
				<view class='text'>一份好的{{type==1?'工作':'职位'}}描述，更能获得{{type==1?'学校/机构':'优秀教师'}}的青睐！</view>
				<view class='text'>1.岗位职责</view>
				<view class='text'>2.{{type==1?'工作成果':'岗位要求'}}</view>
			</view>
			<textarea class='input' :focus="focus" @input="input_text" maxlength="-1" :value="text"  v-else />
		</view>
		<view class='con_btn' @click="confirm_desc()">保存</view>
	</view>
</template>

<script>
	export default{
		data(){
			return {
				type: 1,
				focus: false,
				text: ''
			}
		},
		onLoad(options) {
			this.type=options.type;
			if(options.type==2){
				uni.setNavigationBarTitle({
					title: "职位描述"
				})
			}
			this.text=options.data.replace(/<br \/>/g,'\n');
			console.log(this.text);
		},
		methods:{
			chage_focus(){
				this.focus=true
			},
			input_text(e){
				this.text=e.detail.value
			},
			confirm_desc(){
				var pages = getCurrentPages();
				var prevPage = pages[pages.length - 2];
				prevPage.$vm.workDescribe=this.text;
				uni.navigateBack({
					delta: 1
				})
			},
		}
	}
</script>

<style lang="scss">
	.page_cont{
		width: 100%;
		.box{
			padding: 32rpx 0;
			margin: 0 32rpx;
			border-bottom: 2rpx solid #F7F9FB;
			.text_wrap{
				width: 100%;
				.text{
					text-align: left;
					height: 40rpx;
					font-size: 28rpx;
					font-weight: 400;
					line-height: 40rpx;
					color: rgba(121,133,148,0.5);
					margin-bottom: 32rpx;
					&:nth-child(2){
						margin-bottom: 12rpx;
					}
					&:last-child{
						margin-bottom: 0;
					}
				}
			}
			.input{
				width: 100%;
				height: 300rpx;
				font-size: 28rpx;
				font-weight: 400;
				line-height: 40rpx;
				color: rgba(121,133,148,1);
			}
		}
		.con_btn{
			position: fixed;
			bottom: 32rpx;
			left: 32rpx;
			width: 686rpx;
			height: 104rpx;
			text-align: center;
			line-height: 104rpx;
			font-size: 36rpx;
			font-weight: 400;
			color: #fff;
			background: #5B90FF;
			border-radius: 16rpx;
		}
	}
</style>
